Factor out gtk_box_pack from gtk_box_pack_start and gtk_box_pack_end to reduce code...
authorMikael Hallendal <micke@imendio.com>
Sat, 28 Jun 2008 16:16:26 +0000 (16:16 +0000)
committerMikael Hallendal <hallski@src.gnome.org>
Sat, 28 Jun 2008 16:16:26 +0000 (16:16 +0000)
2008-06-27  Mikael Hallendal  <micke@imendio.com>

        * gtk/gtkbox.c (gtk_box_pack, gtk_box_pack_start, gtk_box_pack_end):
        Factored out gtk_box_pack from gtk_box_pack_start and use it from both
        pack_start and pack_end in order to reduce the code duplication.

svn path=/trunk/; revision=20700

ChangeLog
gtk/gtkbox.c

index 0b45d7bc89f8c3c16631d6a54951c46074d0639e..5dfc3d2a1bcae39d48dc73eaa98d02ab9938b07d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-27  Mikael Hallendal  <micke@imendio.com>
+
+       * gtk/gtkbox.c (gtk_box_pack, gtk_box_pack_start, gtk_box_pack_end):
+       Factored out gtk_box_pack from gtk_box_pack_start and use it from both
+       pack_start and pack_end in order to reduce the code duplication.
+
 2008-06-27  Michael Natterer  <mitch@imendio.com>
 
        Bug 442042 – GtkScaleButton is too limited
index 457bd0a356b9f89da484e5fc6d84e8c84a10e4e1..bc81a7698ad4d30a3eca3f82017168ab29a20382 100644 (file)
@@ -329,6 +329,43 @@ gtk_box_get_child_property (GtkContainer *container,
     }
 }
 
+static void
+gtk_box_pack (GtkBox      *box,
+              GtkWidget   *child,
+              gboolean     expand,
+              gboolean     fill,
+              guint        padding,
+              GtkPackType  pack_type)
+{
+  GtkBoxChild *child_info;
+
+  g_return_if_fail (GTK_IS_BOX (box));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (child->parent == NULL);
+
+  child_info = g_new (GtkBoxChild, 1);
+  child_info->widget = child;
+  child_info->padding = padding;
+  child_info->expand = expand ? TRUE : FALSE;
+  child_info->fill = fill ? TRUE : FALSE;
+  child_info->pack = pack_type;
+  child_info->is_secondary = FALSE;
+
+  box->children = g_list_append (box->children, child_info);
+
+  gtk_widget_freeze_child_notify (child);
+
+  gtk_widget_set_parent (child, GTK_WIDGET (box));
+  
+  gtk_widget_child_notify (child, "expand");
+  gtk_widget_child_notify (child, "fill");
+  gtk_widget_child_notify (child, "padding");
+  gtk_widget_child_notify (child, "pack-type");
+  gtk_widget_child_notify (child, "position");
+  gtk_widget_thaw_child_notify (child);
+             
+}
+
 /**
  * gtk_box_pack_start:
  * @box: a #GtkBox
@@ -358,32 +395,7 @@ gtk_box_pack_start (GtkBox    *box,
                    gboolean   fill,
                    guint      padding)
 {
-  GtkBoxChild *child_info;
-
-  g_return_if_fail (GTK_IS_BOX (box));
-  g_return_if_fail (GTK_IS_WIDGET (child));
-  g_return_if_fail (child->parent == NULL);
-
-  child_info = g_new (GtkBoxChild, 1);
-  child_info->widget = child;
-  child_info->padding = padding;
-  child_info->expand = expand ? TRUE : FALSE;
-  child_info->fill = fill ? TRUE : FALSE;
-  child_info->pack = GTK_PACK_START;
-  child_info->is_secondary = FALSE;
-
-  box->children = g_list_append (box->children, child_info);
-
-  gtk_widget_freeze_child_notify (child);
-
-  gtk_widget_set_parent (child, GTK_WIDGET (box));
-  
-  gtk_widget_child_notify (child, "expand");
-  gtk_widget_child_notify (child, "fill");
-  gtk_widget_child_notify (child, "padding");
-  gtk_widget_child_notify (child, "pack-type");
-  gtk_widget_child_notify (child, "position");
-  gtk_widget_thaw_child_notify (child);
+  gtk_box_pack (box, child, expand, fill, padding, GTK_PACK_START);
 }
 
 /**
@@ -415,32 +427,7 @@ gtk_box_pack_end (GtkBox    *box,
                  gboolean   fill,
                  guint      padding)
 {
-  GtkBoxChild *child_info;
-
-  g_return_if_fail (GTK_IS_BOX (box));
-  g_return_if_fail (GTK_IS_WIDGET (child));
-  g_return_if_fail (child->parent == NULL);
-
-  child_info = g_new (GtkBoxChild, 1);
-  child_info->widget = child;
-  child_info->padding = padding;
-  child_info->expand = expand ? TRUE : FALSE;
-  child_info->fill = fill ? TRUE : FALSE;
-  child_info->pack = GTK_PACK_END;
-  child_info->is_secondary = FALSE;
-
-  box->children = g_list_append (box->children, child_info);
-
-  gtk_widget_freeze_child_notify (child);
-
-  gtk_widget_set_parent (child, GTK_WIDGET (box));
-
-  gtk_widget_child_notify (child, "expand");
-  gtk_widget_child_notify (child, "fill");
-  gtk_widget_child_notify (child, "padding");
-  gtk_widget_child_notify (child, "pack-type");
-  gtk_widget_child_notify (child, "position");
-  gtk_widget_thaw_child_notify (child);
+  gtk_box_pack (box, child, expand, fill, padding, GTK_PACK_END);
 }
 
 /**